package com.speoki.springboot.mapper;


import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Mapper
@Repository
public interface CourseMapper {
    int deleteByPrimaryKey(Integer cno);

    int insert(Course record);

    int insertSelective(Course record);

    Course selectByPrimaryKey(Integer cno);
/*List<CourseAvg> getAvgCourse();*/

List<Course> getAll();

//3
    @Select("select course.Cname as Cname,avg(sc.Grade) as average from course, sc where course.Cno=sc.Cno GROUP BY sc.Cno;")
  List<Map<String,Object>> getCourseAvg2();

    //2
@Select("select student.Sname as sname,Course.Cname as cname from student,course,sc where  sc.Sno = student.Sno And course.Cno =sc.Cno")
List<Map<String,String>> getStudentCourse();

    int updateByPrimaryKeySelective(Course record);

    int updateByPrimaryKey(Course record);
}